import {
	resolve
} from 'path'
import {
	defineConfig,
	externalizeDepsPlugin
} from 'electron-vite'
import vue from '@vitejs/plugin-vue'

import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import {
	ElementPlusResolver
} from 'unplugin-vue-components/resolvers'

import vitePluginResolve from 'vite-plugin-resolve'

export default defineConfig({
	main: {
		plugins: [externalizeDepsPlugin()]
	},
	preload: {
		plugins: [externalizeDepsPlugin()]
	},
	renderer: {
		resolve: {
			alias: {
				'@renderer': resolve('src/renderer/src')
			}
		},
		plugins: [
			vue(),
			AutoImport({
				resolvers: [ElementPlusResolver()],
			}),
			Components({
				resolvers: [ElementPlusResolver()],
			}),
			vitePluginResolve({
				      "trtc-electron-sdk": `
			          const TRTCCloud = require('trtc-electron-sdk');
			          const TRTCAudioRecordingParams = TRTCCloud.TRTCAudioRecordingParams;
			          const TRTCParams = TRTCCloud.TRTCParams;
			          const TRTCAppScene = TRTCCloud.TRTCAppScene;
			          const TRTCVideoStreamType = TRTCCloud.TRTCVideoStreamType;
			          const TRTCScreenCaptureSourceType = TRTCCloud.TRTCScreenCaptureSourceType;
			          const TRTCVideoEncParam = TRTCCloud.TRTCVideoEncParam;
			          const Rect = TRTCCloud.Rect;
			          const TRTCAudioQuality = TRTCCloud.TRTCAudioQuality;
			          const TRTCScreenCaptureSourceInfo = TRTCCloud.TRTCScreenCaptureSourceInfo;
			          const TRTCDeviceInfo = TRTCCloud.TRTCDeviceInfo;
			          const TRTCVideoQosPreference = TRTCCloud.TRTCVideoQosPreference;
			          const TRTCQualityInfo = TRTCCloud.TRTCQualityInfo;
			          const TRTCQuality = TRTCCloud.TRTCQuality;
			          const TRTCStatistics = TRTCCloud.TRTCStatistics;
			          const TRTCVolumeInfo = TRTCCloud.TRTCVolumeInfo;
			          const TRTCDeviceType = TRTCCloud.TRTCDeviceType;
			          const TRTCDeviceState = TRTCCloud.TRTCDeviceState;
			          const TRTCBeautyStyle = TRTCCloud.TRTCBeautyStyle;
			          const TRTCVideoResolution = TRTCCloud.TRTCVideoResolution;
			          const TRTCVideoResolutionMode = TRTCCloud.TRTCVideoResolutionMode;
			          const TRTCVideoMirrorType = TRTCCloud.TRTCVideoMirrorType;
			          const TRTCVideoRotation = TRTCCloud.TRTCVideoRotation;
			          const TRTCVideoFillMode = TRTCCloud.TRTCVideoFillMode;
			          const TRTCRoleType = TRTCCloud.TRTCRoleType;
			          const TRTCScreenCaptureProperty = TRTCCloud.TRTCScreenCaptureProperty;
			          export { 
						TRTCAudioRecordingParams,
			            TRTCParams,
			            TRTCAppScene,
			            TRTCVideoStreamType,
			            TRTCScreenCaptureSourceType,
			            TRTCVideoEncParam,
			            Rect,
			            TRTCAudioQuality,
			            TRTCScreenCaptureSourceInfo,
			            TRTCDeviceInfo,
			            TRTCVideoQosPreference,
			            TRTCQualityInfo,
			            TRTCStatistics,
			            TRTCVolumeInfo,
			            TRTCDeviceType,
			            TRTCDeviceState,
			            TRTCBeautyStyle,
			            TRTCVideoResolution,
			            TRTCVideoResolutionMode,
			            TRTCVideoMirrorType,
			            TRTCVideoRotation,
			            TRTCVideoFillMode,
			            TRTCRoleType,
			            TRTCQuality,
			            TRTCScreenCaptureProperty,
			          };
			          export default TRTCCloud.default;
			        `
				})
				
				
		]		
	}
})